#-*- coding:utf-8 -*-
import unittest
import HTMLTestRunnerPlugins
import time

test_dir = './test_unittest'
#   运行的测试用例，加到测试套件中
discover = unittest.defaultTestLoader.discover(test_dir)
#   测试报告路径及名称
report_dir = './report'
now = time.strftime("%Y-%m-%d %H_%M_%S")
report_filename = report_dir+'/'+now+'report.html'
# with open(report_filename,'wb') as fp:
#     #   生成测试报告
#     runner = HTMLTestRunnerPlugins.HTMLTestRunner(
#         title="jenkins自动化测试报告测试",
#         description="登录接口自动化",
#         stream = fp
#     )
with open(report_filename, "wb") as fp:
    # 5.使用第三方插件执行并生成测试报告
    runner = HTMLTestRunnerPlugins.HTMLTestRunner(
        title="jenkins自动化测试报告测试",
        description="登录接口自动化",
        stream=fp
    )
    runner.run(discover)
